import { TypeOrmModuleOptions } from "@nestjs/typeorm";
import { RedisOptions } from "ioredis";

declare interface IAppConfig {
    sqlConfig: TypeOrmModuleOptions,
    redisConfig: RedisOptions,
    basicAuth: {
        username: string,
        password: string,
    },
    debug: boolean,
    serverTimeStamp: number,
    /**
     * 过期时间
     */
    userExpiryTime: number,
    encryptKey: string,
    dataEncryptKey: string,
    port: number
}

export const appConfig: IAppConfig = {
    sqlConfig: {
        type: 'mysql',
        host: '127.0.0.1',
        port: 3306,
        username: 'root',
        password: 'root3306',
        database: 'exam',
        synchronize: true,
        entities: [__dirname + '/**/**.entity{.ts,.js}'],
        cache: true,
        extra: {
            charset: 'utf8mb4_general_ci',
        },
        logger: 'advanced-console',
        logging: true
    },
    redisConfig: {
        host: '127.0.0.1',
        port: 6379,
        keyPrefix: 'exam_',
        db: 2
    },
    basicAuth: {
        username: 'exam',
        password: 'LpzJSb3C',
    },
    debug: true,
    serverTimeStamp: 60,
    encryptKey: 'o8PrCwvlIJAZ@LSo',
    port: 3000,
    userExpiryTime: 2,
    dataEncryptKey: "8PrCwvZ@LSo!@#"
};
